﻿cmake_minimum_required(VERSION 3.5)

project(distance_display LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# QtCreator supports the following variables for Android, which are identical to qmake Android variables.
# Check http://doc.qt.io/qt-5/deployment-android.html for more information.
# They need to be set before the find_package(Qt5 ...) call.

#if(ANDROID)
#    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
#    if (ANDROID_ABI STREQUAL "armeabi-v7a")
#        set(ANDROID_EXTRA_LIBS
#            ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libcrypto.so
#            ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libssl.so)
#    endif()
#endif()
#set_target_properties(WIN32_ICON "${CMAKE_SOURCE_DIR}/image/1.ico")

include_directories(
    .
    weye/app/include
    weye/core/include
)

file(GLOB_RECURSE weye_app_files "weye/app/source/*.c")
file(GLOB_RECURSE weye_core_files "weye/core/source/*.c")

#aux_source_directory(weye/core/source weye_core_files)

MESSAGE( STATUS "start1")
MESSAGE( STATUS "weye_app_files = ${weye_app_files}.")
MESSAGE( STATUS "start2")
MESSAGE( STATUS "weye_core_files = ${weye_core_files}.")

#file(GLOB_RECURSE weye_app_files_h weye/app/include/*.h)
#file(GLOB_RECURSE weye_core_files_h weye/core/include/*.h)


#MESSAGE( STATUS "start3")
#MESSAGE( STATUS "weye_app_files = ${weye_app_files_h}.")
#MESSAGE( STATUS "start4")
#MESSAGE( STATUS "weye_core_files = ${weye_core_files_h}.")

#set(weye_source_files "")

#file(APPEND weye_source_files weye_app_files)
#file(APPEND weye_source_files weye_core_files)

#MESSAGE( STATUS "start3")
#MESSAGE( STATUS "weye_source_files = ${weye_source_files}.")

set(QRC_SOURCE_FILES ${CMAKE_SOURCE_DIR}/icon.qrc)
set(RC_SOURCE_FILES ${CMAKE_SOURCE_DIR}/icon.rc)

find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets SerialPort Charts LinguistTools REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets SerialPort Charts LinguistTools REQUIRED)

set(TS_FILES distance_display_zh_CN.ts)

if(ANDROID)
  add_library(distance_display SHARED
    main.cpp
    mainwindow.cpp
    mainwindow.h
    mainwindow.ui
    serial_dev.cpp
    serial_dev.h
    ChartView.cpp
    ChartView.h
    ${weye_source_files}
    ${TS_FILES}
    ${QRC_SOURCE_FILES}
    ${RC_SOURCE_FILES}
  )
else()
  add_executable(distance_display WIN32
    main.cpp
    mainwindow.cpp
    mainwindow.h
    mainwindow.ui
    serial_dev.cpp
    serial_dev.h
    ChartView.cpp
    ChartView.h
    ${weye_core_files}
    ${weye_app_files}
    #${weye_core_files_h}
    #${weye_app_files_h}
    ${TS_FILES}
    tracker1D_api.h
    tracker1D_api.c
    ${QRC_SOURCE_FILES}
    ${RC_SOURCE_FILES}
  )
endif()

target_link_libraries(distance_display PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::SerialPort Qt${QT_VERSION_MAJOR}::Charts)

qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
